const http = require('http')

const server = http.createServer((req, res) => {
  res.setHeader('Content-type', 'application/json')
  console.log('cur time', Date.now());
  console.error('模拟出错', Date.now());
  // 模拟一个错误
  if(req.url === '/err'){
    throw new Error('/err 出错了')
  }
  res.end(
    JSON.stringify({
      errno: 0,
      msg: 'pm2 test server'
    })
  )
})

server.listen(8000)
console.log('server is listening on port 8000 ...');